<?php
declare (strict_types = 1);

namespace app\model;

use think\Model;

/**
 * @property array $goods_json 商品信息
 * @property array $sku_json 规格
 * @property bool $pay_status 支付状态:0=未支付,1=进行中,2=已过期,3=待分配
 * @property bool $pay_type 支付方式:1=微信,2=支付宝
 * @property float $amount 金额
 * @property int $expiretime 过期时间
 * @property int $goods_id 商品
 * @property int $id
 * @property int $paytime 支付时间
 * @property int $service_user_id 客服
 * @property int $users_id 用户
 * @property string $createtime
 * @property string $order_sn 订单编号
 * @property-read \app\model\TalentGoods $goods
 * @property-read \app\model\Users $service
 * @property-read \app\model\Users $users
 * @property-read mixed $pay_status_text
 * @property-read mixed $pay_type_text
 * @mixin \think\Model
 */
class TalentGoodsOrders extends Model
{
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
	
	protected $type = [
		'goods_json'=>'json',
		'sku_json'=>'json',
	];
	protected $append = [
		'pay_status_text',
		'pay_type_text'
	];
	function goods()
	{
		return $this->belongsTo(TalentGoods::class,'goods_id');
	}
	
	function users()
	{
		return $this->belongsTo(Users::class,'users_id');
	}
	
	function service()
	{
		return $this->belongsTo(Users::class,'service_user_id');
	}
	
	function getPayStatusTextAttr($value,$data)
	{
		$value = $value ?? $data['pay_status'];
		$list = ['0' => '待付款', '1' => '进行中','2'=>'已过期','3'=>'待分配'];
		return $list[$value] ?? '';
	}
	
	function getPayTypeTextAttr($value,$data)
	{
		$value = $value ?? $data['pay_type'];
		$list = [ '1' => '微信','2'=>'支付宝'];
		return $list[$value] ?? '';
	}
	
}
